package siga.visao_financeiro;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.visao.index;
import siga.visao.verErros;
import siga.visao_busca.buscaVer;


public class cadFornecedorVer extends javax.swing.JInternalFrame {
    Boolean novacidade = false;
    List cod_cidade = new ArrayList();
    public cadFornecedorVer() {
        initComponents();
        jfDescricao.requestFocus();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpPrincipal = new javax.swing.JPanel();
        barraFerramentaFonecedor = new javax.swing.JToolBar();
        btNovo = new javax.swing.JButton();
        btAlterar = new javax.swing.JButton();
        btCancelar = new javax.swing.JButton();
        btSalvar = new javax.swing.JButton();
        btRemover = new javax.swing.JButton();
        btBuscar = new javax.swing.JButton();
        btSair = new javax.swing.JButton();
        jpFCad = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jfDescricao = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jfTipo = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jfNacionalidade = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        jfCNPJ = new javax.swing.JFormattedTextField();
        jLabel7 = new javax.swing.JLabel();
        jfContato = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jfEndereco = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jfNr = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jfBairro = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jfPais = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jfEstado = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        jfCidade = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        jfCEP = new javax.swing.JFormattedTextField();
        jLabel15 = new javax.swing.JLabel();
        jfComplemento = new javax.swing.JTextField();
        jfTelefone = new javax.swing.JFormattedTextField();
        jLabel3 = new javax.swing.JLabel();
        jfTelLoja = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jfTelCelular = new javax.swing.JFormattedTextField();
        jLabel16 = new javax.swing.JLabel();
        jfEmail = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Cadastro de Fornecedor");
        setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/Business_People_16x16.png"))); // NOI18N
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });

        barraFerramentaFonecedor.setFloatable(false);
        barraFerramentaFonecedor.setRollover(true);

        btNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/novo_32x32.png"))); // NOI18N
        btNovo.setMnemonic('N');
        btNovo.setText("Novo");
        btNovo.setToolTipText("Inseri um Novo Cadastro");
        btNovo.setFocusable(false);
        btNovo.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btNovo.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btNovoActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btNovo);

        btAlterar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/editar_32x32.png"))); // NOI18N
        btAlterar.setMnemonic('A');
        btAlterar.setText("Alterar");
        btAlterar.setToolTipText("Alterar um  Cadastro");
        btAlterar.setEnabled(false);
        btAlterar.setFocusable(false);
        btAlterar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btAlterar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btAlterar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlterarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btAlterar);

        btCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/cancelar_32x32.png"))); // NOI18N
        btCancelar.setMnemonic('C');
        btCancelar.setText("Cancelar");
        btCancelar.setToolTipText("Cancelar um Cadastro");
        btCancelar.setEnabled(false);
        btCancelar.setFocusable(false);
        btCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btCancelar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btCancelar);

        btSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/salvar_32x32.png"))); // NOI18N
        btSalvar.setMnemonic('S');
        btSalvar.setText("Salvar");
        btSalvar.setToolTipText("Salvar um Cadastro");
        btSalvar.setEnabled(false);
        btSalvar.setFocusable(false);
        btSalvar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSalvar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSalvarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSalvar);

        btRemover.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/remover_32x32.png"))); // NOI18N
        btRemover.setMnemonic('R');
        btRemover.setText("Remover");
        btRemover.setToolTipText("Remove um Cadastro");
        btRemover.setEnabled(false);
        btRemover.setFocusable(false);
        btRemover.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btRemover.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btRemover.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btRemoverActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btRemover);

        btBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/buscar_32x32.png"))); // NOI18N
        btBuscar.setMnemonic('B');
        btBuscar.setText("Busca");
        btBuscar.setToolTipText("Busca um Cadastro");
        btBuscar.setFocusable(false);
        btBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btBuscar.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBuscarActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btBuscar);

        btSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/sair_32x32.png"))); // NOI18N
        btSair.setMnemonic('S');
        btSair.setText("Sair");
        btSair.setToolTipText("Sair da Janela");
        btSair.setFocusable(false);
        btSair.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btSair.setMargin(new java.awt.Insets(2, 2, 2, 4));
        btSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSairActionPerformed(evt);
            }
        });
        barraFerramentaFonecedor.add(btSair);

        jLabel1.setText("Nome Fantasia:");

        jfDescricao.setEnabled(false);

        jLabel2.setText("Tipo:");

        jfTipo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Fornecedor" }));
        jfTipo.setEnabled(false);

        jLabel5.setText("Nacionalidade:");

        jfNacionalidade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Brasileiro", "Estrangeiro" }));
        jfNacionalidade.setEnabled(false);

        jLabel6.setText("CNPJ:");

        try {
            jfCNPJ.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###/####-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfCNPJ.setEnabled(false);

        jLabel7.setText("Contato:");

        jfContato.setEnabled(false);

        jLabel8.setText("Endereço:");

        jfEndereco.setEnabled(false);

        jLabel9.setText("Número");

        jfNr.setEnabled(false);

        jLabel10.setText("Bairro:");

        jfBairro.setEnabled(false);

        jLabel11.setText("País:");

        jfPais.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Brasil", " " }));
        jfPais.setEnabled(false);

        jLabel12.setText("Estado:");

        jfEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SC", "PR", "RJ", "RS", "MG", "SP", " " }));
        jfEstado.setEnabled(false);
        jfEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jfEstadoActionPerformed(evt);
            }
        });

        jLabel13.setText("Cidade:");

        jfCidade.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Capivari de Baixo", "Tubarão" }));
        jfCidade.setEnabled(false);

        jLabel14.setText("CEP:");

        try {
            jfCEP.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#####-###")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfCEP.setEnabled(false);

        jLabel15.setText("Complemento:");

        jfComplemento.setEnabled(false);

        try {
            jfTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelefone.setEnabled(false);

        jLabel3.setText("Telefone Comercial:");

        try {
            jfTelLoja.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelLoja.setEnabled(false);

        jLabel4.setText("Telefone Loja:");

        try {
            jfTelCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jfTelCelular.setEnabled(false);

        jLabel16.setText("Telefone Celular:");

        jfEmail.setEnabled(false);

        jLabel17.setText("E-Mail:");

        javax.swing.GroupLayout jpFCadLayout = new javax.swing.GroupLayout(jpFCad);
        jpFCad.setLayout(jpFCadLayout);
        jpFCadLayout.setHorizontalGroup(
            jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFCadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jpFCadLayout.createSequentialGroup()
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel2)
                                    .addComponent(jfTipo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel1)
                                    .addComponent(jfDescricao, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)))
                            .addGroup(jpFCadLayout.createSequentialGroup()
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jfNacionalidade, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jfCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jfContato, javax.swing.GroupLayout.DEFAULT_SIZE, 559, Short.MAX_VALUE)))
                            .addGroup(jpFCadLayout.createSequentialGroup()
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jpFCadLayout.createSequentialGroup()
                                        .addComponent(jfPais, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jfEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jpFCadLayout.createSequentialGroup()
                                        .addComponent(jLabel11)
                                        .addGap(86, 86, 86)
                                        .addComponent(jLabel12)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel13)
                                    .addComponent(jfCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(14, 14, 14)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jfCEP, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel14))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel15)
                                    .addComponent(jfComplemento, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpFCadLayout.createSequentialGroup()
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8)
                                    .addComponent(jfEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 584, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jfNr)
                                    .addComponent(jLabel9))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel10)
                                    .addComponent(jfBairro, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addContainerGap())
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jfTelefone)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jfTelLoja, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16)
                            .addComponent(jfTelCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jpFCadLayout.createSequentialGroup()
                                .addComponent(jLabel17)
                                .addGap(339, 339, 339))
                            .addGroup(jpFCadLayout.createSequentialGroup()
                                .addComponent(jfEmail)
                                .addContainerGap())))))
        );
        jpFCadLayout.setVerticalGroup(
            jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpFCadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jfNacionalidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfCNPJ, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfContato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jfEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jfNr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jfBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jfPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(jLabel14)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jfCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfCEP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jfComplemento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpFCadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelLoja, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfTelCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpFCadLayout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jfEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(280, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jpPrincipalLayout = new javax.swing.GroupLayout(jpPrincipal);
        jpPrincipal.setLayout(jpPrincipalLayout);
        jpPrincipalLayout.setHorizontalGroup(
            jpPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.DEFAULT_SIZE, 804, Short.MAX_VALUE)
            .addComponent(jpFCad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jpPrincipalLayout.setVerticalGroup(
            jpPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpPrincipalLayout.createSequentialGroup()
                .addComponent(barraFerramentaFonecedor, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpFCad, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSairActionPerformed
       setVisible(false);
       dispose();
    }//GEN-LAST:event_btSairActionPerformed

    private void btBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBuscarActionPerformed
        index.LRpessoa.add(0,"");
        index.LRpessoa.add(1,"");
        buscaVer.setTipo("Fornecedor");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            if(!index.LRpessoa.get(0).equals("")){
                try {
                    conexao.Query("select * from pessoas where codigo=" + index.LRpessoa.get(0).toString() + " and cod_emp=" + index.cod_emp);
                    conexao.rs.next();
                    jfDescricao.setText(index.LRpessoa.get(1).toString());
                    if(conexao.rs.getString("nacionalidade")!=null){
                        jfNacionalidade.setSelectedItem((conexao.rs.getString("nacionalidade").equals("B"))?"Brasileiro":"Estrangeiro");
                    }
                    jfContato.setText((conexao.rs.getString("obs")!=null)?conexao.rs.getString("obs"):"");
                    jfCNPJ.setText((conexao.rs.getString("cpf")!=null)?conexao.rs.getString("cpf"):"   .   .   /    -  ");
                    jfEndereco.setText((conexao.rs.getString("logradouro")!=null)?conexao.rs.getString("logradouro"):"");
                    jfNr.setText((conexao.rs.getString("nro_log")!=null)?conexao.rs.getString("nro_log"):"");
                    jfBairro.setText((conexao.rs.getString("bairro")!=null)?conexao.rs.getString("bairro"):"");
                    jfCEP.setText((conexao.rs.getString("cep")!=null)?conexao.rs.getString("cep"):"    -   ");
                    jfComplemento.setText((conexao.rs.getString("comp_log")!=null)?conexao.rs.getString("comp_log"):"");
                    jfTelefone.setText((conexao.rs.getString("telefone")!=null)?conexao.rs.getString("telefone"):"(  )    -    ");
                    jfTelCelular.setText((conexao.rs.getString("celular")!=null)?conexao.rs.getString("celular"):"(  )    -    ");
                    jfTelLoja.setText((conexao.rs.getString("telefone_com")!=null)?conexao.rs.getString("telefone_com"):"(  )    -    ");
                    jfEmail.setText((conexao.rs.getString("email")!=null)?conexao.rs.getString("email"):"");
                    if(conexao.rs.getString("cod_cidade")!=null){
                        conexao.Query("select * from end_cidade where codigo="+conexao.rs.getString("cod_cidade"));
                        conexao.rs.next();
                        jfCidade.setSelectedItem(conexao.rs.getString("descricao"));
                        jfEstado.setSelectedItem(conexao.rs.getString("sigla"));
                    }
                } catch (SQLException ex) {
                    verErros.setErro("(Busca):"+ex.getMessage());
                }
                btAlterar.setEnabled(true);
            }
        }
    }//GEN-LAST:event_btBuscarActionPerformed

    private void btNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btNovoActionPerformed
        btCancelarActionPerformed(evt);
        CamposLimpa();
        Campos(true);
        CampoEstadoCarrega();
        CampoPaisCarrega();
        CampoCidadeCarrega();
        jfDescricao.requestFocus();
        btNovo.setEnabled(false);
        btSalvar.setEnabled(true);
        btCancelar.setEnabled(true);
        novacidade = true;
        conexao.AutoIncrementa("pessoas");
    }//GEN-LAST:event_btNovoActionPerformed

    private void btAlterarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlterarActionPerformed
        Campos(true);
        jfDescricao.requestFocus();
        btNovo.setEnabled(false);
        btAlterar.setEnabled(false);
        btSalvar.setEnabled(true);
        btCancelar.setEnabled(true);
    }//GEN-LAST:event_btAlterarActionPerformed

    private void btCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelarActionPerformed
        novacidade = false;
        CamposLimpa();
        Campos(false);
         btNovo.setEnabled(true);
        btAlterar.setEnabled(false);
        btSalvar.setEnabled(false);
        btCancelar.setEnabled(false);
        conexao.RemoveAutoIncrementa("pessoas");
    }//GEN-LAST:event_btCancelarActionPerformed

    private void jfEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jfEstadoActionPerformed
        if(novacidade == true){
            CampoCidadeCarrega();
        }
    }//GEN-LAST:event_jfEstadoActionPerformed

    private void formInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameClosed
        conexao.RemoveAutoIncrementa("pessoas");
    }//GEN-LAST:event_formInternalFrameClosed

    private void btSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSalvarActionPerformed
        if(!jfDescricao.getText().equals("")){
            if (conexao.AutoIncRS != null) {
                index.LRpessoa.set(0, conexao.AutoIncRS);
                index.LRpessoa.set(1, jfDescricao.getText());
                conexao.AutoIncRS = null;
            }
            String ops = (jfCNPJ.getText().equals("        /    -  "))?"":",cpf=\""+jfCNPJ.getText()+"\"";
            ops += (jfContato.getText().equals(""))?"":",obs=\""+jfContato.getText()+"\"";
            ops += (jfTelefone.getText().equals("((  )    -    "))?"":",telefone=\""+jfTelefone.getText()+"\"";
            ops += (jfTelLoja.getText().equals("(  )    -    "))?"":",telefone_com=\""+jfTelLoja.getText()+"\"";
            ops += (jfTelCelular.getText().equals("(  )    -    "))?"":",celular=\""+jfTelCelular.getText()+"\"";
            ops += (jfEmail.getText().equals(""))?"":",email=\""+jfEmail.getText()+"\"";
            ops += (jfEndereco.getText().equals(""))?"":",logradouro=\""+jfEndereco.getText()+"\"";
            ops += (jfNr.getText().equals(""))?"":",nro_log=\""+jfNr.getText()+"\"";
            ops += (jfBairro.getText().equals(""))?"":",bairro=\""+jfBairro.getText()+"\"";
            ops += (jfCEP.getText().equals("     -   "))?"":",cep=\""+jfCEP.getText()+"\"";
            ops += (jfComplemento.getText().equals(""))?"":",comp_log=\""+jfComplemento.getText()+"\"";
            ops += (jfCidade.getSelectedIndex()==0)?"":",cod_cidade=\""+cod_cidade.get(jfCidade.getSelectedIndex())+"\"";
            conexao.Inserir("update pessoas set descricao=\""+jfDescricao.getText()+"\",tipo=\"Fornecedor\" "+ops+"  where cod_emp="+index.cod_emp+" and codigo="+index.LRpessoa.get(0));
            btNovo.setEnabled(true);
            btAlterar.setEnabled(false);
            btSalvar.setEnabled(false);
            btCancelar.setEnabled(false);
        }else{
            JOptionPane.showMessageDialog(null,"Campo Nome Fantasia é obrigatório.","Informação do Sistema",JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_btSalvarActionPerformed

    private void btRemoverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btRemoverActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btRemoverActionPerformed
    private void Campos(boolean tipo){
        jfBairro.setEnabled(tipo);
        jfCEP.setEnabled(tipo);
        jfCNPJ.setEnabled(tipo);
        jfCidade.setEnabled(tipo);
        jfComplemento.setEnabled(tipo);
        jfDescricao.setEnabled(tipo);
        jfEndereco.setEnabled(tipo);
        jfEstado.setEnabled(tipo);
        jfContato.setEnabled(tipo);
        jfNacionalidade.setEnabled(tipo);
        jfNr.setEnabled(tipo);
        jfPais.setEnabled(tipo);
        jfTipo.setEnabled(tipo);
        jfTelefone.setEnabled(tipo);
        jfTelLoja.setEnabled(tipo);
        jfTelCelular.setEnabled(tipo);
        jfEmail.setEnabled(tipo);
    }

    private void CamposLimpa(){
        jfBairro.setText("");
        jfCEP.setText("");
        jfCNPJ.setText("");
        jfComplemento.setText("");
        jfDescricao.setText("");
        jfEndereco.setText("");
        jfContato.setText("");
        jfNr.setText("");
        jfEmail.setText("");
        jfTelefone.setText("(  )    -    ");
        jfTelLoja.setText("(  )    -    ");
        jfTelCelular.setText("(  )    -    ");
    }

    private void CampoEstadoCarrega(){
        try {
            conexao.Query("select codigo, sigla from end_estados order by sigla");
            jfEstado.removeAllItems();
            while (conexao.rs.next()) {
                jfEstado.addItem(conexao.rs.getString("sigla"));
            }
            jfEstado.setSelectedItem("SC");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void CampoPaisCarrega(){
        try {
            conexao.Query("select codigo, descricao from end_pais order by descricao");
            jfPais.removeAllItems();
            while (conexao.rs.next()) {
                jfPais.addItem(conexao.rs.getString("descricao"));
            }
            jfPais.setSelectedItem("BRASIL");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    private void CampoCidadeCarrega(){
        try {
            conexao.Query("select codigo, descricao from end_cidade where sigla=\"" + jfEstado.getSelectedItem() + "\" order by descricao");
            jfCidade.removeAllItems();
            while (conexao.rs.next()) {
                cod_cidade.add(conexao.rs.getString("codigo"));
                jfCidade.addItem(conexao.rs.getString("descricao"));
            }
            jfCidade.setSelectedItem("CAPIVARI DE BAIXO");
        } catch (SQLException ex) {
            verErros.setErro(ex.getMessage());
        }
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barraFerramentaFonecedor;
    private javax.swing.JButton btAlterar;
    private javax.swing.JButton btBuscar;
    private javax.swing.JButton btCancelar;
    private javax.swing.JButton btNovo;
    private javax.swing.JButton btRemover;
    private javax.swing.JButton btSair;
    private javax.swing.JButton btSalvar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jfBairro;
    private javax.swing.JFormattedTextField jfCEP;
    private javax.swing.JFormattedTextField jfCNPJ;
    private javax.swing.JComboBox jfCidade;
    private javax.swing.JTextField jfComplemento;
    private javax.swing.JTextField jfContato;
    private javax.swing.JTextField jfDescricao;
    private javax.swing.JTextField jfEmail;
    private javax.swing.JTextField jfEndereco;
    private javax.swing.JComboBox jfEstado;
    private javax.swing.JComboBox jfNacionalidade;
    private javax.swing.JTextField jfNr;
    private javax.swing.JComboBox jfPais;
    private javax.swing.JFormattedTextField jfTelCelular;
    private javax.swing.JFormattedTextField jfTelLoja;
    private javax.swing.JFormattedTextField jfTelefone;
    private javax.swing.JComboBox jfTipo;
    private javax.swing.JPanel jpFCad;
    private javax.swing.JPanel jpPrincipal;
    // End of variables declaration//GEN-END:variables

}
